Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor]: private model store #7570

Closed
wants to merge 4 commits into from
Closed

[Refactor]: private model store #7570

wants to merge 4 commits into from

Conversation

snewcomer
Copy link
Contributor

@snewcomer snewcomer commented May 30, 2021

WIP

  • One single store. We can simplify the system by combining our two stores and use HAS_MODEL_PACKAGE to remove code if the end user does not have @ember-data/model installed.
    - [ ] Move private APIs to _privateStore as delegate for internal code.

@snewcomer snewcomer added 🎯 canary PR is targeting canary (default) 🏷️ feat This PR introduces a new feature labels May 30, 2021
@snewcomer snewcomer self-assigned this May 30, 2021
@github-actions
Copy link

github-actions bot commented May 30, 2021

Asset Size Report for afd5d80

IE11 Builds

✅ EmberData shrank by -1007.0 B (-49.0 B compressed)

If any packages had changed sizes they would be listed here.

Changeset


EmberData +196.61 KB -1007.0 B (+40.57 KB -49.0 B compressed)
    @ember-data/store +80.08 KB -1007.0 B (+16.52 KB -49.0 B compressed)
        @ember-data/store/-private +79.17 KB -1007.0 B (+16.33 KB -49.0 B compressed)

Full Asset Analysis (IE11)

Asset Size Report
=================


Library: EmberData
┌────────────┬─────────────┐
│  (index)   │   Values    │
├────────────┼─────────────┤
│   bytes    │ '196.61 KB' │
│ compressed │ '40.57 KB'  │
│  packages  │      8      │
│  modules   │     44      │
└────────────┴─────────────┘

Package: @ember-data/store
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '80.08 KB' │
│  compressed  │ '16.52 KB' │
│ % Of Library │   '40.7'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/store/-private                        | 79.17 KB  | 16.33 KB   | 98.9          | 40.3
	@ember-data/store/index                           | 936.00 B  | 193.13 B   | 1.1           | 0.5

Package: @ember-data/model
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '32.11 KB' │
│  compressed  │ '6.63 KB'  │
│ % Of Library │   '16.3'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/model/-private                        | 31.63 KB  | 6.53 KB    | 98.5          | 16.1
	@ember-data/model/index                           | 486.00 B  | 100.27 B   | 1.5           | 0.2

Package: @ember-data/record-data
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '25.74 KB' │
│  compressed  │ '5.31 KB'  │
│ % Of Library │   '13.1'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/record-data/-private                  | 25.74 KB  | 5.31 KB    | 100.0         | 13.1

Package: @ember-data/serializer
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '21.13 KB' │
│  compressed  │ '4.36 KB'  │
│ % Of Library │   '10.7'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/serializer/json                       | 7.84 KB   | 1.62 KB    | 37.1          | 4.0
	@ember-data/serializer/-private                   | 5.81 KB   | 1.20 KB    | 27.5          | 3.0
	@ember-data/serializer/json-api                   | 3.96 KB   | 836.27 B   | 18.7          | 2.0
	@ember-data/serializer/rest                       | 3.04 KB   | 643.35 B   | 14.4          | 1.5
	@ember-data/serializer/index                      | 273.00 B  | 56.32 B    | 1.3           | 0.1
	@ember-data/serializer/transform                  | 215.00 B  | 44.36 B    | 1.0           | 0.1

Package: @ember-data/adapter
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '17.92 KB' │
│  compressed  │ '3.70 KB'  │
│ % Of Library │   '9.1'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/adapter/rest                          | 9.22 KB   | 1.90 KB    | 51.5          | 4.7
	@ember-data/adapter/-private                      | 3.84 KB   | 811.31 B   | 21.4          | 2.0
	@ember-data/adapter/error                         | 1.98 KB   | 417.62 B   | 11.0          | 1.0
	@ember-data/adapter/index                         | 1.51 KB   | 319.20 B   | 8.4           | 0.8
	@ember-data/adapter/json-api                      | 1.37 KB   | 289.48 B   | 7.6           | 0.7

Package: ember-data
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '9.49 KB' │
│  compressed  │ '1.96 KB' │
│ % Of Library │   '4.8'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-data/index                                  | 2.42 KB   | 510.47 B   | 25.5          | 1.2
	ember-data/-private                               | 2.12 KB   | 448.16 B   | 22.4          | 1.1
	ember-data/adapters/errors                        | 1.19 KB   | 251.11 B   | 12.5          | 0.6
	ember-data/setup-container                        | 520.00 B  | 107.29 B   | 5.4           | 0.3
	ember-data/relationships                          | 318.00 B  | 65.61 B    | 3.3           | 0.2
	ember-data/serializers/embedded-records-mixin     | 274.00 B  | 56.53 B    | 2.8           | 0.1
	ember-data/serializers/json-api                   | 251.00 B  | 51.79 B    | 2.6           | 0.1
	ember-data/adapters/json-api                      | 245.00 B  | 50.55 B    | 2.5           | 0.1
	ember-data/serializers/json                       | 243.00 B  | 50.13 B    | 2.5           | 0.1
	ember-data/serializers/rest                       | 243.00 B  | 50.13 B    | 2.5           | 0.1
	ember-data/transform                              | 241.00 B  | 49.72 B    | 2.5           | 0.1
	ember-data/adapters/rest                          | 237.00 B  | 48.90 B    | 2.4           | 0.1
	ember-data/serializer                             | 232.00 B  | 47.86 B    | 2.4           | 0.1
	ember-data/adapter                                | 226.00 B  | 46.63 B    | 2.3           | 0.1
	ember-data/model                                  | 222.00 B  | 45.80 B    | 2.3           | 0.1
	ember-data/store                                  | 222.00 B  | 45.80 B    | 2.3           | 0.1
	ember-data/attr                                   | 218.00 B  | 44.98 B    | 2.2           | 0.1
	ember-data/version                                | 162.00 B  | 33.42 B    | 1.7           | 0.1

Package: ember-inflector
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '7.07 KB' │
│  compressed  │ '1.46 KB' │
│ % Of Library │   '3.6'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-inflector/lib/system/inflector              | 3.11 KB   | 656.96 B   | 44.0          | 1.6
	ember-inflector/lib/system/inflections            | 1.59 KB   | 335.70 B   | 22.5          | 0.8
	ember-inflector/lib/helpers/pluralize             | 506.00 B  | 104.40 B   | 7.0           | 0.3
	ember-inflector/index                             | 473.00 B  | 97.59 B    | 6.5           | 0.2
	ember-inflector/lib/system                        | 471.00 B  | 97.18 B    | 6.5           | 0.2
	ember-inflector/lib/utils/make-helper             | 352.00 B  | 72.62 B    | 4.9           | 0.2
	ember-inflector/lib/system/string                 | 332.00 B  | 68.50 B    | 4.6           | 0.2
	ember-inflector/lib/helpers/singularize           | 296.00 B  | 61.07 B    | 4.1           | 0.1

Package: @ember-data/debug
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '3.07 KB'  │
│  compressed  │ '648.30 B' │
│ % Of Library │   '1.6'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/debug/index                           | 2.58 KB   | 545.13 B   | 84.1          | 1.3
	@ember-data/debug/setup                           | 500.00 B  | 103.16 B   | 15.9          | 0.2

Modern Builds

☑️ EmberData shrank by -611.0 B but the compressed size increased slighty (+4.0 B compressed)

If any packages had changed sizes they would be listed here.

Changeset


EmberData +177.88 KB -611.0 B (+38.85 KB +4.0 B compressed)
    @ember-data/store +70.93 KB -611.0 B (+15.49 KB +4.0 B compressed)
        @ember-data/store/-private +70.02 KB -611.0 B (+15.29 KB +4.0 B compressed)

Full Asset Analysis (Modern)

Asset Size Report
=================


Library: EmberData
┌────────────┬─────────────┐
│  (index)   │   Values    │
├────────────┼─────────────┤
│   bytes    │ '177.88 KB' │
│ compressed │ '38.85 KB'  │
│  packages  │      8      │
│  modules   │     44      │
└────────────┴─────────────┘

Package: @ember-data/store
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '70.93 KB' │
│  compressed  │ '15.49 KB' │
│ % Of Library │   '39.9'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/store/-private                        | 70.02 KB  | 15.29 KB   | 98.7          | 39.4
	@ember-data/store/index                           | 936.00 B  | 204.44 B   | 1.3           | 0.5

Package: @ember-data/model
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '28.56 KB' │
│  compressed  │ '6.24 KB'  │
│ % Of Library │   '16.1'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/model/-private                        | 28.08 KB  | 6.13 KB    | 98.3          | 15.8
	@ember-data/model/index                           | 486.00 B  | 106.15 B   | 1.7           | 0.3

Package: @ember-data/record-data
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '23.77 KB' │
│  compressed  │ '5.19 KB'  │
│ % Of Library │   '13.4'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/record-data/-private                  | 23.77 KB  | 5.19 KB    | 100.0         | 13.4

Package: @ember-data/serializer
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '19.65 KB' │
│  compressed  │ '4.29 KB'  │
│ % Of Library │   '11.0'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/serializer/json                       | 7.21 KB   | 1.58 KB    | 36.7          | 4.1
	@ember-data/serializer/-private                   | 5.49 KB   | 1.20 KB    | 27.9          | 3.1
	@ember-data/serializer/json-api                   | 3.73 KB   | 833.51 B   | 19.0          | 2.1
	@ember-data/serializer/rest                       | 2.76 KB   | 617.70 B   | 14.1          | 1.6
	@ember-data/serializer/index                      | 258.00 B  | 56.35 B    | 1.3           | 0.1
	@ember-data/serializer/transform                  | 215.00 B  | 46.96 B    | 1.1           | 0.1

Package: @ember-data/adapter
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '15.98 KB' │
│  compressed  │ '3.49 KB'  │
│ % Of Library │   '9.0'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/adapter/rest                          | 8.12 KB   | 1.77 KB    | 50.8          | 4.6
	@ember-data/adapter/-private                      | 3.77 KB   | 843.56 B   | 23.6          | 2.1
	@ember-data/adapter/error                         | 1.94 KB   | 434.44 B   | 12.2          | 1.1
	@ember-data/adapter/index                         | 1.10 KB   | 245.72 B   | 6.9           | 0.6
	@ember-data/adapter/json-api                      | 1.04 KB   | 233.27 B   | 6.5           | 0.6

Package: ember-data
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '9.49 KB' │
│  compressed  │ '2.07 KB' │
│ % Of Library │   '5.3'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-data/index                                  | 2.42 KB   | 540.38 B   | 25.5          | 1.4
	ember-data/-private                               | 2.12 KB   | 474.42 B   | 22.4          | 1.2
	ember-data/adapters/errors                        | 1.19 KB   | 265.82 B   | 12.5          | 0.7
	ember-data/setup-container                        | 520.00 B  | 113.58 B   | 5.4           | 0.3
	ember-data/relationships                          | 318.00 B  | 69.45 B    | 3.3           | 0.2
	ember-data/serializers/embedded-records-mixin     | 274.00 B  | 59.84 B    | 2.8           | 0.2
	ember-data/serializers/json-api                   | 251.00 B  | 54.82 B    | 2.6           | 0.1
	ember-data/adapters/json-api                      | 245.00 B  | 53.51 B    | 2.5           | 0.1
	ember-data/serializers/json                       | 243.00 B  | 53.07 B    | 2.5           | 0.1
	ember-data/serializers/rest                       | 243.00 B  | 53.07 B    | 2.5           | 0.1
	ember-data/transform                              | 241.00 B  | 52.64 B    | 2.5           | 0.1
	ember-data/adapters/rest                          | 237.00 B  | 51.76 B    | 2.4           | 0.1
	ember-data/serializer                             | 232.00 B  | 50.67 B    | 2.4           | 0.1
	ember-data/adapter                                | 226.00 B  | 49.36 B    | 2.3           | 0.1
	ember-data/model                                  | 222.00 B  | 48.49 B    | 2.3           | 0.1
	ember-data/store                                  | 222.00 B  | 48.49 B    | 2.3           | 0.1
	ember-data/attr                                   | 218.00 B  | 47.61 B    | 2.2           | 0.1
	ember-data/version                                | 162.00 B  | 35.38 B    | 1.7           | 0.1

Package: ember-inflector
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '6.70 KB' │
│  compressed  │ '1.46 KB' │
│ % Of Library │   '3.8'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-inflector/lib/system/inflector              | 2.88 KB   | 644.13 B   | 43.0          | 1.6
	ember-inflector/lib/system/inflections            | 1.59 KB   | 355.37 B   | 23.7          | 0.9
	ember-inflector/index                             | 473.00 B  | 103.31 B   | 6.9           | 0.3
	ember-inflector/lib/system                        | 471.00 B  | 102.87 B   | 6.9           | 0.3
	ember-inflector/lib/helpers/pluralize             | 373.00 B  | 81.47 B    | 5.4           | 0.2
	ember-inflector/lib/utils/make-helper             | 352.00 B  | 76.88 B    | 5.1           | 0.2
	ember-inflector/lib/system/string                 | 318.00 B  | 69.45 B    | 4.6           | 0.2
	ember-inflector/lib/helpers/singularize           | 296.00 B  | 64.65 B    | 4.3           | 0.2

Package: @ember-data/debug
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '2.81 KB'  │
│  compressed  │ '628.19 B' │
│ % Of Library │   '1.6'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/debug/index                           | 2.32 KB   | 519.19 B   | 82.6          | 1.3
	@ember-data/debug/setup                           | 499.00 B  | 108.99 B   | 17.4          | 0.3

Modern Builds (No Rollup)

✅ EmberData shrank by -1.06 KB (-46.0 B compressed)

If any packages had changed sizes they would be listed here.

Changeset


EmberData +218.73 KB -1.06 KB (+42.18 KB -46.0 B compressed)
    @ember-data/store +95.91 KB -1.06 KB (+18.5 KB -46.0 B compressed)
        @ember-data/store/-private/system/core-store +17.84 KB +926.0 B (+3.44 KB +39.22 B compressed)
        @ember-data/store/-private/index +3.57 KB -4.0 B (+704.11 B -0.17 B compressed)
        @ember-data/store/-private/system/ds-model-store 0.0 B -1.96 KB (0.0 B -85.05 B compressed)

Full Asset Analysis (Modern)

Asset Size Report
=================


Library: EmberData
┌────────────┬─────────────┐
│  (index)   │   Values    │
├────────────┼─────────────┤
│   bytes    │ '218.73 KB' │
│ compressed │ '42.18 KB'  │
│  packages  │      8      │
│  modules   │     147     │
└────────────┴─────────────┘

Package: @ember-data/store
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '95.91 KB' │
│  compressed  │ '18.50 KB' │
│ % Of Library │   '43.8'   │
└──────────────┴────────────┘
	Module                                                                             | Bytes     | Compressed | % of Package  | % Of Library
	--------------------------------------------------------------------------------------------------------------------------------------
	@ember-data/store/-private/system/core-store                                       | 17.84 KB  | 3.44 KB    | 18.6          | 8.2
	@ember-data/store/-private/system/model/internal-model                             | 14.45 KB  | 2.79 KB    | 15.1          | 6.6
	@ember-data/store/-private/system/model/states                                     | 5.44 KB   | 1.05 KB    | 5.7           | 2.5
	@ember-data/store/-private/system/fetch-manager                                    | 4.95 KB   | 977.00 B   | 5.2           | 2.3
	@ember-data/store/-private/system/store/finders                                    | 4.57 KB   | 903.33 B   | 4.8           | 2.1
	@ember-data/store/-private/system/record-array-manager                             | 4.19 KB   | 826.77 B   | 4.4           | 1.9
	@ember-data/store/-private/identifiers/cache                                       | 3.95 KB   | 779.13 B   | 4.1           | 1.8
	@ember-data/store/-private/index                                                   | 3.57 KB   | 704.11 B   | 3.7           | 1.6
	@ember-data/store/-private/system/store/record-data-store-wrapper                  | 3.41 KB   | 672.67 B   | 3.6           | 1.6
	@ember-data/store/-private/system/snapshot                                         | 3.10 KB   | 611.93 B   | 3.2           | 1.4
	@ember-data/store/-private/system/store/internal-model-factory                     | 2.81 KB   | 554.45 B   | 2.9           | 1.3
	@ember-data/store/-private/system/record-arrays/record-array                       | 2.28 KB   | 450.51 B   | 2.4           | 1.0
	@ember-data/store/-private/system/request-cache                                    | 1.89 KB   | 372.40 B   | 2.0           | 0.9
	@ember-data/store/-private/system/references/has-many                              | 1.53 KB   | 302.59 B   | 1.6           | 0.7
	@ember-data/store/-private/system/schema-definition-service                        | 1.51 KB   | 298.73 B   | 1.6           | 0.7
	@ember-data/store/-private/system/references/belongs-to                            | 1.32 KB   | 261.12 B   | 1.4           | 0.6
	@ember-data/store/-private/system/model/shim-model-class                           | 1.32 KB   | 260.16 B   | 1.4           | 0.6
	@ember-data/store/-private/system/store/serializer-response                        | 1.14 KB   | 225.25 B   | 1.2           | 0.5
	@ember-data/store/-private/identifiers/utils/uuid-v4                               | 1.05 KB   | 207.89 B   | 1.1           | 0.5
	@ember-data/store/-private/system/references/record                                | 982.00 B  | 189.38 B   | 1.0           | 0.4
	@ember-data/store/-private/system/record-arrays/adapter-populated-record-array     | 967.00 B  | 186.49 B   | 1.0           | 0.4
	@ember-data/store/index                                                            | 936.00 B  | 180.51 B   | 1.0           | 0.4
	@ember-data/store/-private/system/references/reference                             | 934.00 B  | 180.12 B   | 1.0           | 0.4
	@ember-data/store/-private/system/internal-model-map                               | 886.00 B  | 170.86 B   | 0.9           | 0.4
	@ember-data/store/-private/system/errors-utils                                     | 798.00 B  | 153.89 B   | 0.8           | 0.4
	@ember-data/store/-private/system/snapshot-record-array                            | 753.00 B  | 145.22 B   | 0.8           | 0.3
	@ember-data/store/-private/system/record-notification-manager                      | 697.00 B  | 134.42 B   | 0.7           | 0.3
	@ember-data/store/-private/system/promise-proxies                                  | 607.00 B  | 117.06 B   | 0.6           | 0.3
	@ember-data/store/-private/system/references                                       | 598.00 B  | 115.32 B   | 0.6           | 0.3
	@ember-data/store/-private/system/store/common                                     | 527.00 B  | 101.63 B   | 0.5           | 0.2
	@ember-data/store/-private/utils/construct-resource                                | 506.00 B  | 97.58 B    | 0.5           | 0.2
	@ember-data/store/-private/system/coerce-id                                        | 496.00 B  | 95.65 B    | 0.5           | 0.2
	@ember-data/store/-private/system/record-arrays                                    | 487.00 B  | 93.92 B    | 0.5           | 0.2
	@ember-data/store/-private/system/identity-map                                     | 450.00 B  | 86.78 B    | 0.5           | 0.2
	@ember-data/store/-private/ts-interfaces/identifier                                | 400.00 B  | 77.14 B    | 0.4           | 0.2
	@ember-data/store/-private/utils/symbol                                            | 393.00 B  | 75.79 B    | 0.4           | 0.2
	@ember-data/store/-private/system/record-data-for                                  | 390.00 B  | 75.21 B    | 0.4           | 0.2
	@ember-data/store/-private/identifiers/is-stable-identifier                        | 327.00 B  | 63.06 B    | 0.3           | 0.1
	@ember-data/store/-private/ts-interfaces/fetch-manager                             | 316.00 B  | 60.94 B    | 0.3           | 0.1
	@ember-data/store/-private/utils/promise-record                                    | 290.00 B  | 55.92 B    | 0.3           | 0.1
	@ember-data/store/-private/system/backburner                                       | 269.00 B  | 51.87 B    | 0.3           | 0.1
	@ember-data/store/-private/system/deprecated-evented                               | 257.00 B  | 49.56 B    | 0.3           | 0.1
	@ember-data/store/-private/system/normalize-model-name                             | 220.00 B  | 42.42 B    | 0.2           | 0.1
	@ember-data/store/-private/utils/is-non-empty-string                               | 212.00 B  | 40.88 B    | 0.2           | 0.1
	@ember-data/store/-debug/index                                                     | 210.00 B  | 40.49 B    | 0.2           | 0.1
	@ember-data/store/-private/ts-interfaces/minimum-serializer-interface              | 169.00 B  | 32.59 B    | 0.2           | 0.1
	@ember-data/store/-private/ts-interfaces/record-data-record-wrapper                | 167.00 B  | 32.20 B    | 0.2           | 0.1
	@ember-data/store/-private/ts-interfaces/minimum-adapter-interface                 | 166.00 B  | 32.01 B    | 0.2           | 0.1
	@ember-data/store/-private/ts-interfaces/record-data-store-wrapper                 | 166.00 B  | 32.01 B    | 0.2           | 0.1
	@ember-data/store/-private/ts-interfaces/schema-definition-service                 | 166.00 B  | 32.01 B    | 0.2           | 0.1
	@ember-data/store/-private/ts-interfaces/record-data-json-api                      | 161.00 B  | 31.04 B    | 0.2           | 0.1
	@ember-data/store/-private/ts-interfaces/ember-data-json-api                       | 160.00 B  | 30.85 B    | 0.2           | 0.1
	@ember-data/store/-private/ts-interfaces/record-data-schemas                       | 160.00 B  | 30.85 B    | 0.2           | 0.1
	@ember-data/store/-private/ts-interfaces/promise-proxies                           | 156.00 B  | 30.08 B    | 0.2           | 0.1
	@ember-data/store/-private/ts-interfaces/record-instance                           | 156.00 B  | 30.08 B    | 0.2           | 0.1
	@ember-data/store/-private/ts-interfaces/record-data                               | 152.00 B  | 29.31 B    | 0.2           | 0.1
	@ember-data/store/-private/ts-interfaces/ds-model                                  | 149.00 B  | 28.73 B    | 0.2           | 0.1
	@ember-data/store/-private/ts-interfaces/utils                                     | 146.00 B  | 28.15 B    | 0.1           | 0.1

Package: @ember-data/model
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '32.63 KB' │
│  compressed  │ '6.29 KB'  │
│ % Of Library │   '14.9'   │
└──────────────┴────────────┘
	Module                                                                | Bytes     | Compressed | % of Package  | % Of Library
	-------------------------------------------------------------------------------------------------------------------------
	@ember-data/model/-private/model                                      | 9.89 KB   | 1.91 KB    | 30.3          | 4.5
	@ember-data/model/-private/record-state                               | 6.17 KB   | 1.19 KB    | 18.9          | 2.8
	@ember-data/model/-private/system/promise-many-array                  | 3.80 KB   | 751.17 B   | 11.7          | 1.7
	@ember-data/model/-private/system/many-array                          | 2.85 KB   | 562.75 B   | 8.7           | 1.3
	@ember-data/model/-private/errors                                     | 2.08 KB   | 411.55 B   | 6.4           | 1.0
	@ember-data/model/-private/index                                      | 1.42 KB   | 280.79 B   | 4.4           | 0.7
	@ember-data/model/-private/system/relationships/relationship-meta     | 1.25 KB   | 247.43 B   | 3.8           | 0.6
	@ember-data/model/-private/attr                                       | 857.00 B  | 165.27 B   | 2.6           | 0.4
	@ember-data/model/-private/notify-changes                             | 845.00 B  | 162.96 B   | 2.5           | 0.4
	@ember-data/model/-private/belongs-to                                 | 687.00 B  | 132.49 B   | 2.1           | 0.3
	@ember-data/model/-private/has-many                                   | 648.00 B  | 124.97 B   | 1.9           | 0.3
	@ember-data/model/index                                               | 486.00 B  | 93.72 B    | 1.5           | 0.2
	@ember-data/model/-private/system/promise-belongs-to                  | 447.00 B  | 86.20 B    | 1.3           | 0.2
	@ember-data/model/-private/util                                       | 442.00 B  | 85.24 B    | 1.3           | 0.2
	@ember-data/model/-private/system/diff-array                          | 438.00 B  | 84.47 B    | 1.3           | 0.2
	@ember-data/model/-private/system/model-for-mixin                     | 431.00 B  | 83.12 B    | 1.3           | 0.2

Package: @ember-data/record-data
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '30.84 KB' │
│  compressed  │ '5.95 KB'  │
│ % Of Library │   '14.1'   │
└──────────────┴────────────┘
	Module                                                                            | Bytes     | Compressed | % of Package  | % Of Library
	-------------------------------------------------------------------------------------------------------------------------------------
	@ember-data/record-data/-private/record-data                                      | 8.21 KB   | 1.58 KB    | 26.6          | 3.8
	@ember-data/record-data/-private/graph/index                                      | 4.86 KB   | 959.64 B   | 15.8          | 2.2
	@ember-data/record-data/-private/graph/operations/replace-related-records         | 3.14 KB   | 620.02 B   | 10.2          | 1.4
	@ember-data/record-data/-private/graph/-edge-definition                           | 2.83 KB   | 558.70 B   | 9.2           | 1.3
	@ember-data/record-data/-private/relationships/state/has-many                     | 2.01 KB   | 396.89 B   | 6.5           | 0.9
	@ember-data/record-data/-private/relationships/state/belongs-to                   | 1.92 KB   | 379.73 B   | 6.2           | 0.9
	@ember-data/record-data/-private/graph/operations/update-relationship             | 1.50 KB   | 296.80 B   | 4.9           | 0.7
	@ember-data/record-data/-private/graph/-utils                                     | 1.05 KB   | 207.31 B   | 3.4           | 0.5
	@ember-data/record-data/-private/graph/operations/replace-related-record          | 1.04 KB   | 204.61 B   | 3.4           | 0.5
	@ember-data/record-data/-private/index                                            | 977.00 B  | 188.41 B   | 3.1           | 0.4
	@ember-data/record-data/-private/graph/operations/add-to-related-records          | 788.00 B  | 151.96 B   | 2.5           | 0.4
	@ember-data/record-data/-private/relationships/state/implicit                     | 692.00 B  | 133.45 B   | 2.2           | 0.3
	@ember-data/record-data/-private/graph/operations/remove-from-related-records     | 667.00 B  | 128.63 B   | 2.1           | 0.3
	@ember-data/record-data/-private/coerce-id                                        | 406.00 B  | 78.29 B    | 1.3           | 0.2
	@ember-data/record-data/-private/graph/-state                                     | 293.00 B  | 56.50 B    | 0.9           | 0.1
	@ember-data/record-data/-private/normalize-link                                   | 238.00 B  | 45.89 B    | 0.8           | 0.1
	@ember-data/record-data/-private/ts-interfaces/relationship-record-data           | 171.00 B  | 32.97 B    | 0.5           | 0.1
	@ember-data/record-data/-private/graph/-operations                                | 150.00 B  | 28.92 B    | 0.5           | 0.1

Package: @ember-data/serializer
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '22.08 KB' │
│  compressed  │ '4.26 KB'  │
│ % Of Library │   '10.1'   │
└──────────────┴────────────┘
	Module                                                     | Bytes     | Compressed | % of Package  | % Of Library
	--------------------------------------------------------------------------------------------------------------
	@ember-data/serializer/json                                | 7.21 KB   | 1.39 KB    | 32.7          | 3.3
	@ember-data/serializer/-private/embedded-records-mixin     | 4.39 KB   | 866.49 B   | 19.9          | 2.0
	@ember-data/serializer/json-api                            | 3.73 KB   | 735.93 B   | 16.9          | 1.7
	@ember-data/serializer/rest                                | 2.76 KB   | 545.39 B   | 12.5          | 1.3
	@ember-data/serializer/-private/index                      | 1.18 KB   | 233.35 B   | 5.4           | 0.5
	@ember-data/serializer/-private/transforms/date            | 523.00 B  | 100.86 B   | 2.3           | 0.2
	@ember-data/serializer/-private/transforms/boolean         | 507.00 B  | 97.77 B    | 2.2           | 0.2
	@ember-data/serializer/-private/transforms/number          | 446.00 B  | 86.01 B    | 2.0           | 0.2
	@ember-data/serializer/-private/transforms/string          | 368.00 B  | 70.97 B    | 1.6           | 0.2
	@ember-data/serializer/-private/utils                      | 303.00 B  | 58.43 B    | 1.3           | 0.1
	@ember-data/serializer/index                               | 258.00 B  | 49.75 B    | 1.1           | 0.1
	@ember-data/serializer/-private/transforms/transform       | 257.00 B  | 49.56 B    | 1.1           | 0.1
	@ember-data/serializer/transform                           | 215.00 B  | 41.46 B    | 1.0           | 0.1

Package: @ember-data/adapter
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '18.11 KB' │
│  compressed  │ '3.49 KB'  │
│ % Of Library │   '8.3'    │
└──────────────┴────────────┘
	Module                                                        | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------------------
	@ember-data/adapter/rest                                      | 8.12 KB   | 1.57 KB    | 44.8          | 3.7
	@ember-data/adapter/error                                     | 1.94 KB   | 383.58 B   | 10.7          | 0.9
	@ember-data/adapter/-private/build-url-mixin                  | 1.93 KB   | 381.85 B   | 10.7          | 0.9
	@ember-data/adapter/index                                     | 1.10 KB   | 216.96 B   | 6.1           | 0.5
	@ember-data/adapter/json-api                                  | 1.04 KB   | 205.96 B   | 5.8           | 0.5
	@ember-data/adapter/-private/index                            | 1.03 KB   | 203.65 B   | 5.7           | 0.5
	@ember-data/adapter/-private/utils/serialize-query-params     | 792.00 B  | 152.74 B   | 4.3           | 0.4
	@ember-data/adapter/-private/utils/determine-body-promise     | 566.00 B  | 109.15 B   | 3.1           | 0.3
	@ember-data/adapter/-private/utils/parse-response-headers     | 480.00 B  | 92.57 B    | 2.6           | 0.2
	@ember-data/adapter/-private/utils/fetch                      | 454.00 B  | 87.55 B    | 2.4           | 0.2
	@ember-data/adapter/-private/utils/serialize-into-hash        | 347.00 B  | 66.92 B    | 1.9           | 0.2
	@ember-data/adapter/-private/utils/continue-on-reject         | 222.00 B  | 42.81 B    | 1.2           | 0.1
	@ember-data/adapter/-private/fastboot-interface               | 147.00 B  | 28.34 B    | 0.8           | 0.1

Package: ember-data
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '9.65 KB' │
│  compressed  │ '1.86 KB' │
│ % Of Library │   '4.4'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-data/index                                  | 2.42 KB   | 477.12 B   | 25.0          | 1.1
	ember-data/-private/index                         | 1.93 KB   | 380.69 B   | 20.0          | 0.9
	ember-data/adapters/errors                        | 1.19 KB   | 234.70 B   | 12.3          | 0.5
	ember-data/setup-container                        | 520.00 B  | 100.28 B   | 5.3           | 0.2
	ember-data/-private/core                          | 366.00 B  | 70.58 B    | 3.7           | 0.2
	ember-data/relationships                          | 318.00 B  | 61.32 B    | 3.2           | 0.1
	ember-data/serializers/embedded-records-mixin     | 274.00 B  | 52.84 B    | 2.8           | 0.1
	ember-data/serializers/json-api                   | 251.00 B  | 48.40 B    | 2.5           | 0.1
	ember-data/adapters/json-api                      | 245.00 B  | 47.24 B    | 2.5           | 0.1
	ember-data/serializers/json                       | 243.00 B  | 46.86 B    | 2.5           | 0.1
	ember-data/serializers/rest                       | 243.00 B  | 46.86 B    | 2.5           | 0.1
	ember-data/transform                              | 241.00 B  | 46.47 B    | 2.4           | 0.1
	ember-data/adapters/rest                          | 237.00 B  | 45.70 B    | 2.4           | 0.1
	ember-data/serializer                             | 232.00 B  | 44.74 B    | 2.3           | 0.1
	ember-data/adapter                                | 226.00 B  | 43.58 B    | 2.3           | 0.1
	ember-data/model                                  | 222.00 B  | 42.81 B    | 2.2           | 0.1
	ember-data/store                                  | 222.00 B  | 42.81 B    | 2.2           | 0.1
	ember-data/attr                                   | 218.00 B  | 42.04 B    | 2.2           | 0.1
	ember-data/version                                | 162.00 B  | 31.24 B    | 1.6           | 0.1

Package: ember-inflector
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '6.70 KB' │
│  compressed  │ '1.29 KB' │
│ % Of Library │   '3.1'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-inflector/lib/system/inflector              | 2.88 KB   | 568.72 B   | 43.0          | 1.3
	ember-inflector/lib/system/inflections            | 1.59 KB   | 313.77 B   | 23.7          | 0.7
	ember-inflector/index                             | 473.00 B  | 91.22 B    | 6.9           | 0.2
	ember-inflector/lib/system                        | 471.00 B  | 90.83 B    | 6.9           | 0.2
	ember-inflector/lib/helpers/pluralize             | 373.00 B  | 71.93 B    | 5.4           | 0.2
	ember-inflector/lib/utils/make-helper             | 352.00 B  | 67.88 B    | 5.1           | 0.2
	ember-inflector/lib/system/string                 | 318.00 B  | 61.32 B    | 4.6           | 0.1
	ember-inflector/lib/helpers/singularize           | 296.00 B  | 57.08 B    | 4.3           | 0.1

Package: @ember-data/debug
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '2.81 KB'  │
│  compressed  │ '554.65 B' │
│ % Of Library │   '1.3'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/debug/index                           | 2.32 KB   | 458.41 B   | 82.6          | 1.1
	@ember-data/debug/setup                           | 499.00 B  | 96.23 B    | 17.4          | 0.2

@github-actions
Copy link

github-actions bot commented May 30, 2021

Performance Report for afd5d80

Scenario - materialization: ☑️ Performance is stable

☑️ duration
phase no difference [-25ms to 10ms]
☑️ Phase [navigationStart] => [start-find-all]
phase no difference [-16ms to 6ms]
☑️ Phase [start-find-all] => [start-materialization]
phase no difference [-14ms to 12ms]
☑️ Phase [start-materialization] => [end-materialization]
phase no difference [-7ms to 3ms]
☑️ Phase [end-materialization] => [Test End]
phase no difference [-1ms to 5ms]

Scenario - unload: ☑️ Performance is stable

☑️ duration
phase no difference [-33ms to 0ms]
✅ Phase [navigationStart] => [start-push-payload]
phase estimated improvement -7ms [-15ms to 0ms] OR -1.01% [-2.05% to -0.03%]
☑️ Phase [start-push-payload] => [start-unload-records]
phase no difference [-22ms to 3ms]
☑️ Phase [start-unload-records] => [end-unload-records]
phase no difference [-3ms to 0ms]
☑️ Phase [end-unload-records] => [Test End]
phase no difference [0ms to 0ms]

Scenario - destroy: ☑️ Performance is stable

☑️ duration
phase no difference [-18ms to 16ms]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-10ms to 2ms]
☑️ Phase [start-push-payload] => [start-destroy-records]
phase no difference [-7ms to 19ms]
☑️ Phase [start-destroy-records] => [end-destroy-records]
phase no difference [-5ms to 2ms]
☑️ Phase [end-destroy-records] => [Test End]
phase no difference [-1ms to 0ms]

Scenario - add-children: ☑️ Performance is stable

☑️ duration
phase no difference [-11ms to 16ms]
☑️ Phase [navigationStart] => [start-push-initial-payload]
phase no difference [-11ms to 9ms]
☑️ Phase [start-push-initial-payload] => [start-push-update-payload]
phase no difference [-3ms to 8ms]
☑️ Phase [start-push-update-payload] => [end-push-update-payload]
phase no difference [-2ms to 2ms]
☑️ Phase [end-push-update-payload] => [Test End]
phase no difference [-1ms to 1ms]

Scenario - unused-relationships: ☑️ Performance is stable

☑️ duration
phase no difference [-20ms to 15ms]
☑️ Phase [navigationStart] => [start-push-payload]
phase no difference [-10ms to 8ms]
☑️ Phase [start-push-payload] => [end-push-payload]
phase no difference [-15ms to 12ms]
☑️ Phase [end-push-payload] => [Test End]
phase no difference [-1ms to 1ms]

Copy link
Contributor

@runspired runspired left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good, and I think we should land just-this and separate out the private stuff in a new PR after this lands. Both because this is still an incremental win and because this will help move forward some additional typescript cleanup (setting allowJs: true)

I'm happy to pair with you to go over the typescript stuff, I think it will take some tinkering to come up with the right answers. We may not get it ideal on this pass but we can always iterate on it later.

identifier: StableRecordIdentifier,
createRecordArgs: { [key: string]: unknown }, // args passed in to store.createRecord() and processed by recordData to be set on creation
recordDataFor: (identifier: RecordIdentifier) => RecordDataRecordWrapper,
createRecordArgs: { [key: string]: any },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be unknown still, does it cause type issues if it stays that way?

createRecordArgs: { [key: string]: unknown }, // args passed in to store.createRecord() and processed by recordData to be set on creation
recordDataFor: (identifier: RecordIdentifier) => RecordDataRecordWrapper,
createRecordArgs: { [key: string]: any },
recordDataFor: (identifier: StableRecordIdentifier) => RecordDataRecordWrapper,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think RecordIdentifier is the correct API here since a user implementation may not have access to the stable one (they honestly should, but our policy is that APIs that come from user-world don't enforce the object being the stable object, we convert it to the stable-object immediately ourselves instead if it is not already).

notificationManager: NotificationManager
): RecordInstance;
): DSModel {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make this DSModel | RecordInstance. If RecordInstance is causing type issues let's pair and figure out what to put here. It's possible it should be DSModel | unknown or similar since a user can do more or less anything. A generic might be the thing to do here.


abstract teardownRecord(record: RecordInstance): void;
teardownRecord(record: DSModel) {
record.destroy();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's wrap the destroy call in HAS_MODEL_PACKAGE and a check to ensure the record has a destroy method / or is one of our records.

Similarly the typing of record here needs to be handled similarly to the return type of instantiateRecord. Making sure that return types of instantiateRecord satisfy the typing of teardownRecord is another reason we may want to look at using generics here if RecordInstance is not working well enough.

} else {
return this.getSchemaDefinitionService().attributesDefinitionFor(modelName);
if (identifier) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can collapse this with the above by making the first if be if (CUSTOM_MODEL_CLASS || !HAS_MODEL_PACKAGE)

} else {
return this.getSchemaDefinitionService().relationshipsDefinitionFor(modelName);
if (identifier) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can similarly collapse this with the above branching

throw 'schema service is only available when custom model class feature flag is on';
}
} else {
if (CUSTOM_MODEL_CLASS) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can collapse this branching with the HAS_MODEL_PACKAGE branch by only instantiating the ds-model schema definition service in the case that the model package is present.

let relationshipsByName = get(modelClass, 'relationshipsByName');
return relationshipsByName.get(key);
}
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar trick for collapsing: if (CUSTOM_MODEL_CLASS || !HAS_MODEL_PACKAGE)

@@ -76,12 +75,12 @@ if (HAS_MODEL_PACKAGE) {

// TODO this should be integrated with the code removal so we can use it together with the if condition
// and not alongside it
function isNotCustomModelClass(store: CoreStore | Store): store is Store {
function isNotCustomModelClass(store: Store): store is Store {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after this lands we should take a closer look at how this type guard is used. (1) we likely shouldn't need the narrowing behavior anymore and (2) The use-case for that narrowing implies somewhere we will want the ability to specify something like Store<Model> as the more properly typed way of enhancing the instantiateRecord/teardownRecord type for these places in the code.

Copy link
Member

@igorT igorT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Results of the ember data meeting today:

  1. The class merging moved to be discussed next week
  2. Type fixes will be done in a separate PR

@runspired
Copy link
Contributor

replaced by #8078 and #8055

@runspired runspired closed this Jul 26, 2022
@runspired runspired deleted the sn/private-store branch November 29, 2022 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎯 canary PR is targeting canary (default) 🏷️ feat This PR introduces a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants